package cheme.ProcessEditor.Parts.Streams.Tag;

import java.util.ArrayList;
import java.util.List;

import cheme.ProcessEditor.Table.ColumnSpan;

public class TableRowData
{
	public List<ColumnSpan> spans = new ArrayList<ColumnSpan>();

	@Override
	public String toString()
	{
		StringBuilder s = new StringBuilder();
		
		for(ColumnSpan span : spans)
		{
			s.append(span.toString() + ", ");
		}
		
		return s.toString();
	}
	
	public int totalWidth()
	{
		int totalWidth = 0;
		for(ColumnSpan span : spans)
		{
			totalWidth += span.width;
		}
		
		return totalWidth;
	}
	
	@Override
	public boolean equals(Object arg0)
	{
		boolean result = arg0 instanceof  TableRowData;
		
		if(true == result)
		{
			TableRowData tableRowData = (TableRowData)arg0;
		
			result &= (tableRowData.spans.size() == spans.size());
					
			for(int i = 0; true == result && i < spans.size(); i++)
			{
				result &= spans.get(i) == tableRowData.spans.get(i);
			}
		}
		
		return result;
	}
}
